{% macro render_pagination(pagination,endpoint) %}
    <nav aria-label="Page navigation">
        <ul class="pagination">
            <li>
                {% if pagination.has_prev %}
                    <a href="{{ url_for(endpoint,page=pagination.prev().page) }}"
                       aria-label="Previous">
                {% else %}
                    <a href="{{ url_for(endpoint,page=1) }}"
                       aria-label="Previous">
                {% endif %}
                <span aria-hidden="true">&laquo;</span>
                </a>
            </li>
            {#                iter_pages()返回pagination的所有页数#}
            {% for page in pagination.iter_pages() %}
                {% if page %}
                    {% if page!=pagination.page %}
                        <li>
                            <a href="{{ url_for(endpoint, page=page) }}">
                                {{ page }}
                            </a>
                        </li>
                    {% else %}
                        <li><a href="">{{ page }}</a></li>
                    {% endif %}
                {% else %}
                    <li><a href="">...</a></li>
                {% endif %}
            {% endfor %}
            <li>
                {% if pagination.has_next %}
                    <a href="{{ url_for(endpoint, page=pagination.next().page ) }}" aria-label="Next">
                {% else %}
                    <a href="">
                {% endif %}
                <span aria-hidden="true">&raquo;</span>
                </a>
            <li>
        </ul>
    </nav>
{% endmacro %}